import java.util.*;


public class Solution {

    public int findPeakElement (int[] nums) {
        // write code here
        if(nums.length == 1){
            return 0;
        }
        if(nums[nums.length - 1] > nums[nums.length - 2]){
            return nums.length - 1;
        }
        for(int i = 1;i<nums.length - 1;i++){
            int left = nums[i - 1];
            int right = nums[i+1];
            if((nums[i]>left)&&(nums[i]>right)){
                return i;
            }
        }
        return 0;
    }
}